<template>
    <div class="semblable-model tentative-superposition-mask">
        <div class="semblable-title">大家都在下</div>
        <ul class="waterfall" style="min-height: 0 !important;">
            <el-space wrap>
                <li class="image-boxs" v-for="(item, index) in recommendList" :key="index" v-show="!item.not_like_show">
                    <div class="model-contrast" v-if="userInfo.isLogin()">
                        <div class="js_favorite_popup" v-if="!item.not_like" @click="productCareClick(item.id, index)">
                            <el-icon :color="item.is_collect ? 'red' : ''">
                                <component is="StarFilled"></component>
                            </el-icon>
                            <span class="balloon-tips">{{ item.is_collect ? '取消收藏' : '收藏' }}</span>
                        </div>
                        <div class="not-like-operate" v-if="!item.not_like" @click="notLikeClick(item.id, index)">
                            <el-icon>
                                <component is="Close"></component>
                            </el-icon>
                            <div class="balloon-tips">
                                <div class="not-like-btn">不喜欢</div>
                            </div>
                        </div>
                    </div>
                    <a class="image-boxs-mask" target="_blank">
                        <div class="cover-images" style="height: 208px;">
                            <img :src="item.image_url" class="load_img" :title="item.title" :alt="item.title">
                            <div class="not-like-css" v-if="item.not_like" style="z-index: 99999999;">
                                <div class="not-like-content">
                                    <div class="not-like-text">该素材已屏蔽</div>
                                    <div class="not-like-cancel-btn" @click="notLikeClick(item.id, index)">取消不喜欢</div>
                                </div>
                            </div>
                        </div>
                        <div class="model-goods-info clearfix">
                            <p class="model-goods-name" :title="item.title">
                                {{ item.title }}
                            </p>
                        </div>
                    </a>
                </li>
            </el-space>
        </ul>
    </div>
</template>
<script lang="ts" setup>
import { ref, computed } from 'vue';
import { productCare, notLike } from '../api/home/index'
import { ElMessage } from 'element-plus';
import { useUserInfo } from '../stores/userInfo'
const props = defineProps(['recommendList']);
const userInfo = useUserInfo() //获取用户信息
//收藏取消收藏
const productCareClick = (id: any, index: any) => {
    productCare({ id: id }).then(res => {
        if (res.code == 1) {
            props.recommendList[index].is_collect = !props.recommendList[index].is_collect
            ElMessage.success(props.recommendList[index].is_collect ? '收藏成功' : '取消收藏成功')
        }
    })
}
//喜不喜欢
const notLikeClick = (id: any, index: any) => {
    notLike({ id: id }).then(res => {
        if (res.code == 1) {
            console.log(1)
            props.recommendList[index].not_like = !props.recommendList[index].not_like
        }
    })
}

</script>
<style>
</style>